1 Imports System.IO
2 Imports System.Windows.Forms
3 Imports System.Net.Mail
4 Imports System.Data.OleDb
5 Imports System.Security.Permissions
6 Imports System.Text
7 Imports System.Security.Cryptography
8
9 Public Class frmAdminENG
10     Dim connstring As String =
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|datadirectory|\sis.accdb"
11     Dim connect As New OleDbConnection
12
13 #Region
"Connections"
14     Public Sub openconnection()
15         If connect.State = ConnectionState.Closed Then
16             connect.ConnectionString = connstring
17             connect.Open()
18         ElseIf connect.State = ConnectionState.Open Then
19             Me.Refresh()
20         End If
21     End Sub
22
23     Public Sub closeconnection()
24         If connect.State = ConnectionState.Open Then
25             connect.Close()
26         ElseIf connect.State = ConnectionState.Closed Then
27             Me.Refresh()
28         End If
29     End Sub
30 #End Region
31
32 #Region
"Buttons"
33 #Region
"HOME"
34     Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
35         enablebtns()
36         btnHome.Enabled = False
37         hidegb()
38         gbHome.Dock = DockStyle.Fill
39         gbHome.Show()
40         clearinputs_home()
41     End Sub
42
43     Private Sub btnHomepost_Click(sender As System.Object, e As System.EventArgs) Handles btnHomepost.Click
44         Dim ntitle As String = txtHometitle.Text.Trim
45         Dim ndescription As String = txtHomedescription.Text.Trim
46         Dim ntime As String = lblTime.Text.Trim &
" " & lblDate.Text.Trim
47
48         If IsNothing(ntitle) = True Then
49             MsgBox(
"Please enter the title of news", MsgBoxStyle.Information, "Error")
50             txtHometitle.Focus()
51         ElseIf ntitle.Length <
3 Then
52             MsgBox(
"News title can't be less than 3 characters", MsgBoxStyle.Information, "Error")
53             txtHometitle.Focus()
54         ElseIf IsNothing(ndescription) = True Then
55             MsgBox(
"Please enter the description of news", MsgBoxStyle.Information, "Error")
56             txtHomedescription.Focus()
57         ElseIf ndescription.Length <
3 Then
58             MsgBox(
"News description can't be less than 3 characters", MsgBoxStyle.Information, "Error")
59             txtHomedescription.Focus()
60         Else
61             
'for log file
62             
'Dim uname As String =frmlogin.lbluname.text
63             Dim uname As String =
"cngirwa"
64             Dim activity As String = uname +
" posted a news with title " + ntitle
65             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
66             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
67             Dim insertlogcmd As New OleDbCommand
68             With insertlogcmd
69                 .CommandText = insertlog
70                 .Connection = connect
71                 .ExecuteNonQuery()
72             End With
73
74             Dim insertqry As String =
"INSERT INTO news(ntitle,ndescription,ntime) VALUES('" + ntitle + "','" + ndescription + "','" + ntime + "')"
75             Dim insertcmd As New OleDbCommand
76             With insertcmd
77                 .CommandText = insertqry
78                 .Connection = connect
79                 .ExecuteNonQuery()
80             End With
81             MsgBox(
"News posted", MsgBoxStyle.Information, "Success")
82             viewnews()
83             clearinputs_home()
84         End If
85     End Sub
86
87     Private Sub btnHomeclear_Click(sender As System.Object, e As System.EventArgs) Handles btnHomeclear.Click
88         clearinputs_home()
89     End Sub
90
91     Private Sub clearinputs_home()
92         txtHometitle.Clear()
93         txtHomedescription.Clear()
94     End Sub
95
96     Private Sub viewnews()
97         Dim selectqry As String =
"SELECT * FROM news"
98         Dim da As OleDbDataAdapter
99         Dim dtset As New DataSet
100         Dim dttable As New DataTable
101         da = New OleDbDataAdapter(selectqry, connect)
102         da.Fill(dtset,
"news")
103         dttable = dtset.Tables(
"news")
104
105         dgvHome.DataSource = dttable
106         dgvHome.ColumnHeadersDefaultCellStyle.Font = New Font(dgvHome.Font, FontStyle.Bold)
107         dgvHome.ForeColor = Color.Black
108         dgvHome.Font = New Font(dgvHome.Font, FontStyle.Regular)
109
110         dgvHome.Columns(
"ID").HeaderText = "News number"
111         dgvHome.Columns(
"ID").Width = 150
112
113         dgvHome.Columns(
"ntitle").HeaderText = "News Title"
114         dgvHome.Columns(
"ntitle").Width = 230
115
116         dgvHome.Columns(
"ndescription").HeaderText = "News Description"
117         dgvHome.Columns(
"ndescription").Width = 478
118
119         dgvHome.Columns(
"ntime").HeaderText = "Time Posted"
120         dgvHome.Columns(
"ntime").Width = 270
121     End Sub
122
123     Private Sub btnHomedelete_Click(sender As System.Object, e As System.EventArgs) Handles btnHomedelete.Click
124         Dim ntitle As String = txtHometitle.Text.Trim
125         Dim ndescription As String = txtHomedescription.Text.Trim
126         Dim ntime As String = lbltimedelete.Text
127         Dim confirmdel As String =
"Are you sure you want to delete news titled " & ntitle & "?"
128         Dim deletemsg As String
129
130         If StrComp(ntitle,
"") = 0 Or IsDBNull(ntitle) = True Then
131             MsgBox(
"Please select a news to delete", MsgBoxStyle.Information, "Error")
132         ElseIf StrComp(ndescription,
"") = 0 Or IsDBNull(ndescription) = True Then
133             MsgBox(
"Please select a news to delete", MsgBoxStyle.Information, "Error")
134         Else
135             
'for log file
136             
'Dim uname As String =frmlogin.lbluname.text
137             Dim uname As String =
"cngirwa"
138             Dim activity As String = uname +
" deleted a news with title " + ntitle
139             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
140             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
141             Dim insertlogcmd As New OleDbCommand
142             With insertlogcmd
143                 .CommandText = insertlog
144                 .Connection = connect
145                 .ExecuteNonQuery()
146             End With
147
148             Dim deleteqry As String =
"DELETE * FROM news WHERE ntime='" + ntime + "'"
149             Dim deletecmd As New OleDbCommand
150             deletemsg = MessageBox.Show(confirmdel,
"Delete news titled " & ntitle & "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
151             If deletemsg = MsgBoxResult.No Then
152                 Me.Refresh()
153             Else
154                 With deletecmd
155                     .CommandText = deleteqry
156                     .Connection = connect
157                     .ExecuteNonQuery()
158                 End With
159                 MsgBox(
"News deleted", MsgBoxStyle.Information, "Success")
160                 txtHometitle.Clear()
161                 txtHomedescription.Clear()
162                 viewnews()
163             End If
164         End If
165     End Sub
166
167     Private Sub dgvHome_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvHome.CellContentClick
168         Dim s As System.Drawing.Point
169         s = dgvHome.CurrentCellAddress
170         Dim dbtitle As String = dgvHome.Item(
"ntitle", s.Y).Value.ToString
171         txtHometitle.Text = dbtitle
172         Dim dbdescription As String = dgvHome.Item(
"ndescription", s.Y).Value.ToString
173         txtHomedescription.Text = dbdescription
174         Dim dbtime As String = dgvHome.Item(
"ntime", s.Y).Value.ToString
175         lbltimedelete.Text = dbtime
176     End Sub
177
178     Private Sub btnHomerefresh_Click(sender As System.Object, e As System.EventArgs) Handles btnHomerefresh.Click
179         viewnews()
180     End Sub
181
182     Private Sub btnhomesearch_Click(sender As System.Object, e As System.EventArgs) Handles btnhomesearch.Click
183         Dim search As String = txthomesearch.Text.Trim
184         If (search =
"" Or IsNothing(search) = True) Then
185             MsgBox(
"Please enter something to search", MsgBoxStyle.Information, "Error")
186             txthomesearch.Focus()
187         Else
188             txthomesearch.Clear()
189             Dim searchqry As String =
"SELECT * FROM news WHERE id LIKE '%" + search + "%' OR ntitle LIKE '%" + search + "%' OR ndescription LIKE '%" + search + "%' OR ntime LIKE '%" + search + "%'"
190             Dim da As OleDbDataAdapter
191             Dim dtset As New DataSet
192             Dim dttable As New DataTable
193             da = New OleDbDataAdapter(searchqry, connect)
194             da.Fill(dtset,
"news")
195             dttable = dtset.Tables(
"news")
196
197             dgvHome.DataSource = dttable
198             dgvHome.ColumnHeadersDefaultCellStyle.Font = New Font(dgvHome.Font, FontStyle.Bold)
199             dgvHome.ForeColor = Color.Black
200             dgvHome.Font = New Font(dgvHome.Font, FontStyle.Regular)
201
202             dgvHome.Columns(
"ID").HeaderText = "News number"
203             dgvHome.Columns(
"ID").Width = 150
204
205             dgvHome.Columns(
"ntitle").HeaderText = "News Title"
206             dgvHome.Columns(
"ntitle").Width = 230
207
208             dgvHome.Columns(
"ndescription").HeaderText = "News Description"
209             dgvHome.Columns(
"ndescription").Width = 478
210
211             dgvHome.Columns(
"ntime").HeaderText = "Time Posted"
212             dgvHome.Columns(
"ntime").Width = 270
213
214         End If
215     End Sub
216 #End Region
217
218 #Region
"ADD STOCK"
219     Private Sub btnAddstock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddstock.Click
220         enablebtns()
221         btnAddstock.Enabled = False
222         hidegb()
223         gbAddstock.Dock = DockStyle.Fill
224         gbAddstock.Show()
225         clearinputs_addstock()
226         lbldateadded.Text =
""
227     End Sub
228
229     Private Sub btnSaveaddstock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveaddstock.Click
230
231         Dim pname As String = txtnameaddstock.Text.Trim
232         Dim pcategory As String = cbcategoryaddstock.Text.Trim
233         Dim pquantity As String = txtquantityaddstock.Text.Trim
234         Dim pbuying As String = txtbuyingpriceaddstock.Text.Trim
235         Dim pselling As String = txtsellpriceaddstock.Text.Trim
236         Dim pinfo As String = txtInfoaddstock.Text.Trim
237         Dim ptime As String = lblTime.Text.Trim &
" " & lblDate.Text.Trim
238
239         If pname.Length <
2 Then
240             MsgBox(
"Product name can not be less than 2 characters", MsgBoxStyle.Information, "Error")
241             txtnameaddstock.Focus()
242         ElseIf pname.Length >
25 Then
243             MsgBox(
"Product name can not be more than 25 characters", MsgBoxStyle.Information, "Error")
244             txtnameaddstock.Focus()
245
246         ElseIf cbcategoryaddstock.Text =
"" Then
247             MsgBox(
"Please select product category", MsgBoxStyle.Information, "Error")
248             cbcategoryaddstock.Focus()
249
250         ElseIf IsNumeric(pquantity) = False Then
251             MsgBox(
"Only numbers are allowed", MsgBoxStyle.Information, "Error")
252             txtquantityaddstock.Focus()
253         ElseIf pquantity.Length >
25 Then
254             MsgBox(
"Product quantity can not be more than 25 digits", MsgBoxStyle.Information, "Error")
255             txtquantityaddstock.Focus()
256
257         ElseIf IsNumeric(pbuying) = False Then
258             MsgBox(
"Only numbers are allowed", MsgBoxStyle.Information, "Error")
259             txtbuyingpriceaddstock.Focus()
260         ElseIf pbuying.Length >
25 Then
261             MsgBox(
"Product buying price can not be more than 25 digits", MsgBoxStyle.Information, "Error")
262             txtbuyingpriceaddstock.Focus()
263
264         ElseIf IsNumeric(pselling) = False Then
265             MsgBox(
"Only numbers are allowed", MsgBoxStyle.Information, "Error")
266             txtsellpriceaddstock.Focus()
267         ElseIf pselling.Length >
25 Then
268             MsgBox(
"Product selling price can not be more than 25 digits", MsgBoxStyle.Information, "Error")
269             txtsellpriceaddstock.Focus()
270
271         ElseIf pinfo.Length <
2 Then
272             MsgBox(
"Product informations can't be less than 2 characters", MsgBoxStyle.Information, "Error")
273             txtInfoaddstock.Focus()
274
275         ElseIf txtInfoaddstock.Text =
"" Then
276             MsgBox(
"Please enter information about the product", MsgBoxStyle.Information, "Error")
277             txtInfoaddstock.Focus()
278
279         ElseIf lbldateadded.Text <>
"" Then
280
281             
'for log file
282             
'Dim uname As String =frmlogin.lbluname.text
283             Dim uname As String =
"cngirwa"
284             Dim activity As String = uname +
" updated a product with name " + pname
285             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
286             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
287             Dim insertlogcmd As New OleDbCommand
288             With insertlogcmd
289                 .CommandText = insertlog
290                 .Connection = connect
291                 .ExecuteNonQuery()
292             End With
293
294             Dim updateqry As String =
"UPDATE stock SET pname='" + pname + "',pcategory='" + pcategory + "',pquantity='" + pquantity + "',pbuying='" + pbuying + "',pselling='" + pselling + "',pinfo='" + pinfo + "',pdate='" + ptime + "' WHERE pdate='" + lbldateadded.Text + "'"
295             Dim updatecmd As New OleDbCommand
296             With updatecmd
297                 .CommandText = updateqry
298                 .Connection = connect
299                 .ExecuteNonQuery()
300             End With
301             MsgBox(
"Product updated successfuly", MsgBoxStyle.Information, "Success")
302             clearinputs_addstock()
303             lbldateadded.Text =
""
304
305         Else
306             
'for log file
307             
'Dim uname As String =frmlogin.lbluname.text
308             Dim uname As String =
"cngirwa"
309             Dim activity As String = uname +
" added a new product with name " + pname
310             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
311             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
312             Dim insertlogcmd As New OleDbCommand
313             With insertlogcmd
314                 .CommandText = insertlog
315                 .Connection = connect
316                 .ExecuteNonQuery()
317             End With
318
319             Dim insertqry As String =
"INSERT INTO stock(pname,pcategory,pquantity,pbuying,pselling,pinfo,pdate) VALUES('" + pname + "','" + pcategory + "','" + pquantity + "','" + pbuying + "','" + pselling + "','" + pinfo + "','" + ptime + "')"
320             Dim insertcmd As New OleDbCommand
321             With insertcmd
322                 .CommandText = insertqry
323                 .Connection = connect
324                 .ExecuteNonQuery()
325             End With
326             MsgBox(
"New product added successfuly", MsgBoxStyle.Information, "Success")
327             clearinputs_addstock()
328             lbldateadded.Text =
""
329         End If
330     End Sub
331
332     Private Sub btnClearaddstock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearaddstock.Click
333         clearinputs_addstock()
334     End Sub
335
336     Private Sub clearinputs_addstock()
337         txtnameaddstock.Clear()
338         txtInfoaddstock.Clear()
339         txtnameaddstock.Clear()
340         txtquantityaddstock.Clear()
341         txtsellpriceaddstock.Clear()
342         txtbuyingpriceaddstock.Clear()
343     End Sub
344 #End Region
345
346 #Region
"VIEW STOCK"
347     Private Sub btnViewstock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewstock.Click
348         enablebtns()
349         btnViewstock.Enabled = False
350         hidegb()
351         gbViewstock.Dock = DockStyle.Fill
352         gbViewstock.Show()
353         viewstock()
354         lblViewstoredelete.Text =
""
355         lblViewstorename.Text =
""
356     End Sub
357
358     Private Sub btnViewstorerefresh_Click(sender As System.Object, e As System.EventArgs) Handles btnViewstorerefresh.Click
359         viewstock()
360     End Sub
361
362     Private Sub viewstock()
363         
'for log file
364         
'Dim uname As String =frmlogin.lbluname.text
365         Dim uname As String =
"cngirwa"
366         Dim activity As String = uname +
" viewed stock "
367         Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
368         Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
369         Dim insertlogcmd As New OleDbCommand
370         With insertlogcmd
371             .CommandText = insertlog
372             .Connection = connect
373             .ExecuteNonQuery()
374         End With
375
376         Dim selectqry As String =
"SELECT * FROM stock"
377         Dim da As OleDbDataAdapter
378         Dim dtset As DataSet
379         Dim dttable As New DataTable
380
381         da = New OleDbDataAdapter(selectqry, connect)
382         dtset = New DataSet
383         da.Fill(dtset,
"stock")
384         dttable = dtset.Tables(
"stock")
385
386         dgvViewstore.DataSource = dttable
387         dgvViewstore.ColumnHeadersDefaultCellStyle.Font = New Font(dgvViewstore.Font, FontStyle.Bold)
388         dgvViewstore.Font = New Font(dgvViewstore.Font, FontStyle.Regular)
389         dgvViewstore.ForeColor = Color.Black
390
391         dgvViewstore.Columns(
"ID").HeaderText = "S/N"
392         dgvViewstore.Columns(
"ID").Width = 35
393
394         dgvViewstore.Columns(
"pname").HeaderText = "Product name"
395         dgvViewstore.Columns(
"pname").Width = 160
396
397         dgvViewstore.Columns(
"pcategory").HeaderText = "Category"
398         dgvViewstore.Columns(
"pcategory").Width = 90
399
400         dgvViewstore.Columns(
"pquantity").HeaderText = "Quantity"
401         dgvViewstore.Columns(
"pquantity").Width = 70
402
403         dgvViewstore.Columns(
"pbuying").HeaderText = "Buying Price"
404         dgvViewstore.Columns(
"pbuying").Width = 70
405
406         dgvViewstore.Columns(
"pselling").HeaderText = "Selling Price"
407         dgvViewstore.Columns(
"pselling").Width = 70
408
409         dgvViewstore.Columns(
"pinfo").HeaderText = "Description of Product"
410         dgvViewstore.Columns(
"pinfo").Width = 370
411
412         dgvViewstore.Columns(
"pdate").HeaderText = "Date"
413         dgvViewstore.Columns(
"pdate").Width = 270
414
415     End Sub
416
417     Private Sub dgvViewstore_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvViewstore.CellContentClick
418         Dim s As System.Drawing.Point
419         s = dgvViewstore.CurrentCellAddress
420         Try
421             Dim dbtime As String = dgvViewstore.Item(
"pdate", s.Y).Value.ToString
422             lblViewstoredelete.Text = dbtime
423             Dim dbname As String = dgvViewstore.Item(
"pname", s.Y).Value.ToString
424             lblViewstorename.Text = dbname
425         Catch ex As Exception
426             MsgBox(
"Please select a product first", MessageBoxIcon.Warning, "Error")
427         End Try
428     End Sub
429
430     Private Sub btnViewstoredelete_Click(sender As System.Object, e As System.EventArgs) Handles btnViewstoredelete.Click
431         Dim pname As String = lblViewstorename.Text
432
433         Dim confirmdel As String =
"Are you sure you want to delete product named " & pname & "?"
434         Dim deletemsg As String
435         Dim ptime As String = lblViewstoredelete.Text
436
437         If ptime =
"" Then
438             MsgBox(
"Please select a product first", MessageBoxIcon.Warning, "Error")
439         Else
440
441             
'for log file
442             
'Dim uname As String =frmlogin.lbluname.text
443             Dim uname As String =
"cngirwa"
444             Dim activity As String = uname +
" deleted a product with name " + pname
445             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
446             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
447             Dim insertlogcmd As New OleDbCommand
448             With insertlogcmd
449                 .CommandText = insertlog
450                 .Connection = connect
451                 .ExecuteNonQuery()
452             End With
453
454             Dim deleteqry As String =
"DELETE * FROM stock WHERE pdate='" + ptime + "'"
455             Dim deletecmd As New OleDbCommand
456             deletemsg = MessageBox.Show(confirmdel,
"Delete product named " & pname, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
457             If deletemsg = MsgBoxResult.No Then
458                 Me.Refresh()
459             Else
460                 With deletecmd
461                     .CommandText = deleteqry
462                     .Connection = connect
463                     .ExecuteNonQuery()
464                 End With
465                 MsgBox(
"Product deleted", MsgBoxStyle.Information, "Success")
466                 lblViewstoredelete.Text =
"delete"
467                 viewstock()
468             End If
469         End If
470     End Sub
471
472     Private Sub btnViewstoreedit_Click(sender As System.Object, e As System.EventArgs) Handles btnViewstoreedit.Click
473         Dim pdate As String = lblViewstoredelete.Text
474         Dim selectqry As String =
"SELECT * FROM stock WHERE pdate='" + pdate + "'"
475
476         If pdate =
"" Then
477             MsgBox(
"Please select a product first", MsgBoxStyle.Information, "Error")
478         Else
479             Dim da As OleDbDataAdapter
480             da = New OleDbDataAdapter(selectqry, connect)
481
482             Dim dtset As DataSet
483             dtset = New DataSet()
484             da.Fill(dtset,
"stock")
485
486             Dim dttable As DataTable
487             dttable = New DataTable()
488             dttable = dtset.Tables(
"stock")
489
490             Dim dbpname, dbpcategory, dbpquantity, dbpbuying, dbpselling, dbpinfo, dbpdate As String
491             For Each temprow In dttable.Rows
492                 dbpname = temprow(
"pname").ToString
493                 dbpcategory = temprow(
"pcategory").ToString
494                 dbpquantity = temprow(
"pquantity").ToString
495                 dbpbuying = temprow(
"pbuying").ToString
496                 dbpselling = temprow(
"pselling").ToString
497                 dbpinfo = temprow(
"pinfo").ToString
498                 dbpdate = temprow(
"pdate").ToString
499             Next
500
501             txtnameaddstock.Text = dbpname
502             cbcategoryaddstock.Text = dbpcategory
503             txtquantityaddstock.Text = dbpquantity
504             txtbuyingpriceaddstock.Text = dbpbuying
505             txtsellpriceaddstock.Text = dbpselling
506             txtInfoaddstock.Text = dbpinfo
507             lbldateadded.Text = dbpdate
508
509             enablebtns()
510             btnAddstock.Enabled = False
511             hidegb()
512             gbAddstock.Dock = DockStyle.Fill
513             gbAddstock.Show()
514         End If
515     End Sub
516
517     Private Sub btnViewstoresearch_Click(sender As System.Object, e As System.EventArgs) Handles btnViewstoresearch.Click
518         Dim search As String = txtViewstoresearch.Text.Trim
519         If (search =
"" Or IsNothing(search) = True) Then
520             MsgBox(
"Please enter something to search", MsgBoxStyle.Information, "Error")
521             txtViewstoresearch.Focus()
522         Else
523             txtViewstoresearch.Clear()
524             Dim searchqry As String =
"SELECT * FROM stock WHERE id LIKE '%" + search + "%' OR pname LIKE '%" + search + "%' OR pcategory LIKE '%" + search + "%' OR pquantity LIKE '%" + search + "%' OR pbuying LIKE '%" + search + "%' OR pselling LIKE '%" + search + "%' OR pinfo LIKE '%" + search + "%' OR pdate LIKE '%" + search + "%'"
525             Dim da As OleDbDataAdapter
526             Dim dtset As DataSet
527             Dim dttable As New DataTable
528
529             da = New OleDbDataAdapter(searchqry, connect)
530             dtset = New DataSet
531             da.Fill(dtset,
"stock")
532             dttable = dtset.Tables(
"stock")
533
534             dgvViewstore.DataSource = dttable
535             dgvViewstore.ColumnHeadersDefaultCellStyle.Font = New Font(dgvViewstore.Font, FontStyle.Bold)
536             dgvViewstore.Font = New Font(dgvViewstore.Font, FontStyle.Regular)
537             dgvViewstore.ForeColor = Color.Black
538
539             dgvViewstore.Columns(
"ID").HeaderText = "S/N"
540             dgvViewstore.Columns(
"ID").Width = 35
541
542             dgvViewstore.Columns(
"pname").HeaderText = "Product name"
543             dgvViewstore.Columns(
"pname").Width = 160
544
545             dgvViewstore.Columns(
"pcategory").HeaderText = "Category"
546             dgvViewstore.Columns(
"pcategory").Width = 90
547
548             dgvViewstore.Columns(
"pquantity").HeaderText = "Quantity"
549             dgvViewstore.Columns(
"pquantity").Width = 70
550
551             dgvViewstore.Columns(
"pbuying").HeaderText = "Buying Price"
552             dgvViewstore.Columns(
"pbuying").Width = 70
553
554             dgvViewstore.Columns(
"pselling").HeaderText = "Selling Price"
555             dgvViewstore.Columns(
"pselling").Width = 70
556
557             dgvViewstore.Columns(
"pinfo").HeaderText = "Description of Product"
558             dgvViewstore.Columns(
"pinfo").Width = 370
559
560             dgvViewstore.Columns(
"pdate").HeaderText = "Date"
561             dgvViewstore.Columns(
"pdate").Width = 270
562         End If
563     End Sub
564 #End Region
565
566 #Region
"VIEW SALES"
567     Private Sub btnViewsales_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewsales.Click
568         enablebtns()
569         btnViewsales.Enabled = False
570         hidegb()
571         gbViewsales.Dock = DockStyle.Fill
572         gbViewsales.Show()
573         viewsales()
574     End Sub
575
576     Private Sub btnViewsalesrefresh_Click(sender As System.Object, e As System.EventArgs) Handles btnViewsalesrefresh.Click
577         viewsales()
578     End Sub
579
580     Private Sub viewsales()
581         
'for log file
582         
'Dim uname As String =frmlogin.lbluname.text
583         Dim uname As String =
"cngirwa"
584         Dim activity As String = uname +
" viewed sales"
585         Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
586         Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
587         Dim insertlogcmd As New OleDbCommand
588         With insertlogcmd
589             .CommandText = insertlog
590             .Connection = connect
591             .ExecuteNonQuery()
592         End With
593
594         Dim selectqry As String =
"SELECT id,pname,pcategory,pquantitysold,pquantityremain,pselling,pprofit,pdate FROM sales"
595
596         Dim da As OleDbDataAdapter
597         da = New OleDbDataAdapter(selectqry, connect)
598
599         Dim dtset As DataSet
600         dtset = New DataSet()
601         da.Fill(dtset,
"sales")
602
603         Dim dttable As DataTable
604         dttable = New DataTable()
605         dttable = dtset.Tables(
"sales")
606
607         dgvViewsales.DataSource = dttable
608         dgvViewsales.ColumnHeadersDefaultCellStyle.Font = New Font(dgvViewsales.Font, FontStyle.Bold)
609         dgvViewsales.Font = New Font(dgvViewsales.Font, FontStyle.Regular)
610         dgvViewsales.ForeColor = Color.Black
611
612         dgvViewsales.Columns(
"ID").HeaderText = "ID"
613         dgvViewsales.Columns(
"ID").Width = 30
614
615         dgvViewsales.Columns(
"pname").HeaderText = "Name"
616         dgvViewsales.Columns(
"pname").Width = 183
617
618         dgvViewsales.Columns(
"pcategory").HeaderText = "Category"
619         dgvViewsales.Columns(
"pcategory").Width = 120
620
621         dgvViewsales.Columns(
"pquantitysold").HeaderText = "Quantity sold"
622         dgvViewsales.Columns(
"pquantitysold").Width = 120
623
624         dgvViewsales.Columns(
"pquantityremain").HeaderText = "Quantity remain"
625         dgvViewsales.Columns(
"pquantityremain").Width = 150
626
627         dgvViewsales.Columns(
"pselling").HeaderText = "Sell Price"
628         dgvViewsales.Columns(
"pselling").Width = 120
629
630         dgvViewsales.Columns(
"pprofit").HeaderText = "Profit"
631         dgvViewsales.Columns(
"pprofit").Width = 120
632
633         dgvViewsales.Columns(
"pdate").HeaderText = "Date Sold"
634         dgvViewsales.Columns(
"pdate").Width = 290
635     End Sub
636
637     Private Sub btnViewsalessearch_Click(sender As System.Object, e As System.EventArgs) Handles btnViewsalessearch.Click
638         Dim search As String = txtViewsalessearch.Text.Trim
639         If (search =
"" Or IsNothing(search) = True) Then
640             MsgBox(
"Please enter something to search", MsgBoxStyle.Information, "Error")
641             txtViewsalessearch.Focus()
642         Else
643             txtViewsalessearch.Clear()
644             Dim searchqry As String =
"SELECT * FROM sales WHERE id LIKE '%" + search + "%' OR pname LIKE '%" + search + "%' OR pcategory LIKE '%" + search + "%' OR pquantitysold LIKE '%" + search + "%' OR pquantityremain LIKE '%" + search + "%' OR pselling LIKE '%" + search + "%' OR pprofit LIKE '%" + search + "%' OR pinfo LIKE '%" + search + "%' OR pdate LIKE '%" + search + "%'"
645             Dim da As OleDbDataAdapter
646             da = New OleDbDataAdapter(searchqry, connect)
647
648             Dim dtset As DataSet
649             dtset = New DataSet()
650             da.Fill(dtset,
"sales")
651
652             Dim dttable As DataTable
653             dttable = New DataTable()
654             dttable = dtset.Tables(
"sales")
655
656             dgvViewsales.DataSource = dttable
657             dgvViewsales.ColumnHeadersDefaultCellStyle.Font = New Font(dgvViewsales.Font, FontStyle.Bold)
658             dgvViewsales.Font = New Font(dgvViewsales.Font, FontStyle.Regular)
659             dgvViewsales.ForeColor = Color.Black
660
661             dgvViewsales.Columns(
"ID").HeaderText = "ID"
662             dgvViewsales.Columns(
"ID").Width = 30
663
664             dgvViewsales.Columns(
"pname").HeaderText = "Name"
665             dgvViewsales.Columns(
"pname").Width = 183
666
667             dgvViewsales.Columns(
"pcategory").HeaderText = "Category"
668             dgvViewsales.Columns(
"pcategory").Width = 120
669
670             dgvViewsales.Columns(
"pquantitysold").HeaderText = "Quantity sold"
671             dgvViewsales.Columns(
"pquantitysold").Width = 120
672
673             dgvViewsales.Columns(
"pquantityremain").HeaderText = "Quantity remain"
674             dgvViewsales.Columns(
"pquantityremain").Width = 150
675
676             dgvViewsales.Columns(
"pselling").HeaderText = "Sell Price"
677             dgvViewsales.Columns(
"pselling").Width = 120
678
679             dgvViewsales.Columns(
"pprofit").HeaderText = "Profit"
680             dgvViewsales.Columns(
"pprofit").Width = 120
681
682             dgvViewsales.Columns(
"pdate").HeaderText = "Date Sold"
683             dgvViewsales.Columns(
"pdate").Width = 290
684         End If
685     End Sub
686 #End Region
687
688 #Region
"REPORT"
689     Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
690         enablebtns()
691         btnReport.Enabled = False
692         hidegb()
693         gbReport.Dock = DockStyle.Fill
694         gbReport.Show()
695
696         
'for log file
697         
'Dim uname As String =frmlogin.lbluname.text
698         Dim uname As String =
"cngirwa"
699         Dim activity As String = uname +
" viewed report "
700         Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
701         Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + uname + "','" + activity + "','" + activitydate + "')"
702         Dim insertlogcmd As New OleDbCommand
703         With insertlogcmd
704             .CommandText = insertlog
705             .Connection = connect
706             .ExecuteNonQuery()
707         End With
708     End Sub
709 #End Region
710
711 #Region
"MANAGE USERS"
712     Private Sub btnManageaccounts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnManageaccounts.Click
713         enablebtns()
714         btnManageaccounts.Enabled = False
715         hidegb()
716         gbManageusers.Dock = DockStyle.Fill
717         gbManageusers.Show()
718         clearinputs_manageuser()
719         viewusers()
720     End Sub
721
722     Private Sub btnManageuseradd_Click(sender As System.Object, e As System.EventArgs) Handles btnManageuseradd.Click
723         Dim fname As String = txtManageuserfname.Text.Trim
724         Dim mname As String = txtManageusermname.Text.Trim
725         Dim lname As String = txtManageuserlname.Text.Trim
726         Dim email As String = txtManageuseremail.Text.Trim
727         Dim dob As String = dtpManageuserdob.Text.Trim
728         Dim sex As String = cbManageusersex.Text.Trim
729         Dim mobile As String = txtManageusermobile.Text.Trim
730         Dim marital As String = cbManageusermarital.Text.Trim
731         Dim role As String = cbManageuserRole.Text.Trim
732         Dim uname As String = txtManageuseruname.Text.Trim
733         Dim pass As String = txtManageuserpassword.Text.Trim
734         Dim cpass As String = txtManageusercpassword.Text.Trim
735         Dim regdate As String = lblTime.Text.Trim &
" " & lblDate.Text.Trim
736         Dim status As String =
"ACTIVE"
737         Dim access As String =
"LOGOUT"
738
739         Dim selecrtqry As String =
"SELECT * FROM users"
740         Dim da As OleDbDataAdapter
741         da = New OleDbDataAdapter(selecrtqry, connect)
742         Dim dtset As DataSet
743         dtset = New DataSet()
744         da.Fill(dtset,
"users")
745         Dim dttable As DataTable
746         dttable = New DataTable()
747         dttable = dtset.Tables(
"users")
748         Dim dbuname As String
749         For Each temprow In dttable.Rows
750             dbuname = temprow(
"uname").ToString
751         Next
752
753         Dim Ue As New UnicodeEncoding()
754         Dim ByteSourceText() As Byte = Ue.GetBytes(pass)
755         Dim Md5 As New MD5CryptoServiceProvider()
756         Dim ByteHash() As Byte = Md5.ComputeHash(ByteSourceText)
757         Convert.ToBase64String(ByteHash)
758         Dim hashPwd As String
759         hashPwd = Convert.ToBase64String(ByteHash)
760
761         If (fname.Length <
4) Then
762             MsgBox(
"First name can not have less than 4 characters", MsgBoxStyle.Information, "Error")
763             txtManageuserfname.Focus()
764         ElseIf fname.Contains(
" ") Then
765             MsgBox(
"Please enter first name correctly", MsgBoxStyle.Information, "Error")
766             txtManageuserfname.Focus()
767         ElseIf fname.Length >
25 Then
768             MsgBox(
"First name can not have more than 25 characters", MsgBoxStyle.Information, "Error")
769             txtManageuserfname.Focus()
770
771         ElseIf (mname.Length <
4) Then
772             MsgBox(
"Middle name can not have less than 4 characters", MsgBoxStyle.Information, "Error")
773             txtManageusermname.Focus()
774         ElseIf mname.Contains(
" ") Then
775             MsgBox(
"Please enter middle name correctly", MsgBoxStyle.Information, "Error")
776             txtManageusermname.Focus()
777         ElseIf fname.Length >
25 Then
778             MsgBox(
"Middle name can not have more than 25 characters", MsgBoxStyle.Information, "Error")
779             txtManageusermname.Focus()
780
781         ElseIf (lname.Length <
4) Then
782             MsgBox(
"Last name can not have less than 4 characters", MsgBoxStyle.Information, "Error")
783             txtManageuserlname.Focus()
784         ElseIf lname.Contains(
" ") Then
785             MsgBox(
"Please enter last name correctly", MsgBoxStyle.Information, "Error")
786             txtManageuserlname.Focus()
787         ElseIf lname.Length >
25 Then
788             MsgBox(
"Last name can not have more than 25 characters", MsgBoxStyle.Information, "Error")
789             txtManageuserlname.Focus()
790
791         ElseIf (email.Length <
4) Then
792             MsgBox(
"E-Mail address can not have less than 4 characters", MsgBoxStyle.Information, "Error")
793             txtManageuseremail.Focus()
794         ElseIf (email.Contains(
"@") = False) Or (email.Contains(".") = False) Then
795             MsgBox(
"Please enter E-Mail address correctly", MsgBoxStyle.Information, "Error")
796             txtManageuseremail.Focus()
797         ElseIf email.Contains(
" ") Then
798             MsgBox(
"Please enter E-Mail address correctly", MsgBoxStyle.Information, "Error")
799             txtManageuseremail.Focus()
800         ElseIf email.Length >
50 Then
801             MsgBox(
"E-Mail can not have more than 50 characters", MsgBoxStyle.Information, "Error")
802             txtManageuseremail.Focus()
803
804         ElseIf sex =
"" Then
805             MsgBox(
"Please select sex", MsgBoxStyle.Information, "Error")
806             cbManageusersex.Focus()
807
808         ElseIf (mobile.Length <
10) Then
809             MsgBox(
"Mobile number can not have less than 10 digits", MsgBoxStyle.Information, "Error")
810             txtManageusermobile.Focus()
811         ElseIf (mobile.Length >
15) Then
812             MsgBox(
"Mobile number can not have more than 15 digits", MsgBoxStyle.Information, "Error")
813             txtManageusermobile.Focus()
814         ElseIf (IsNumeric(mobile) = False) Then
815             MsgBox(
"Only numbers are allowed", MsgBoxStyle.Information, "Error")
816             txtManageusermobile.Focus()
817
818         ElseIf marital =
"" Then
819             MsgBox(
"Please select marital status", MsgBoxStyle.Information, "Error")
820             cbManageusermarital.Focus()
821
822         ElseIf role =
"" Then
823             MsgBox(
"Please select a role", MsgBoxStyle.Information, "Error")
824             cbManageuserRole.Focus()
825
826         ElseIf (uname.Length <
4) Then
827             MsgBox(
"Username can not have less than 4 characters", MsgBoxStyle.Information, "Error")
828             txtManageuseruname.Focus()
829         ElseIf uname.Contains(
" ") Then
830             MsgBox(
"Please enter username correctly", MsgBoxStyle.Information, "Error")
831             txtManageuseruname.Focus()
832         ElseIf uname.Length >
15 Then
833             MsgBox(
"Username can not have more than 15 characters", MsgBoxStyle.Information, "Error")
834             txtManageuseruname.Focus()
835
836         ElseIf (pass.Length <
6) Then
837             MsgBox(
"Password can not have less than 6 characters", MsgBoxStyle.Information, "Error")
838             txtManageuserpassword.Focus()
839
840         ElseIf (cpass.Length <
6) Then
841             MsgBox(
"Password can not have less than 6 characters", MsgBoxStyle.Information, "Error")
842             txtManageusercpassword.Focus()
843
844         ElseIf (StrComp(pass, cpass) <>
0) Then
845             MsgBox(
"Password did not match. Please enter password correctly", MsgBoxStyle.Information, "Error")
846             txtManageuserpassword.Focus()
847
848         ElseIf (dbuname = uname) Then
849             Dim question As String
850             question = MessageBox.Show(
"User exists. Do you wish to update user information?", "Stationary Information System", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
851             If question = MsgBoxResult.No Then
852                 Me.Refresh()
853                 clearinputs_manageuser()
854                 viewusers()
855             Else
856
857                 
'for log file
858                 
'Dim uname As String =frmlogin.lbluname.text
859                 Dim unamelog As String =
"cngirwa"
860                 Dim activity As String = unamelog +
" updated informations of user with username " + uname
861                 Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
862                 Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
863                 Dim insertlogcmd As New OleDbCommand
864                 With insertlogcmd
865                     .CommandText = insertlog
866                     .Connection = connect
867                     .ExecuteNonQuery()
868                 End With
869
870
871                 Dim updateqry As String =
"UPDATE users SET fname='" + fname + "',mname='" + mname + "',lname='" + lname + "',email='" + email + "',dob='" + dob + "',sex='" + sex + "',mobile='" + mobile + "',marital='" + marital + "',role='" + role + "',uname='" + uname + "',upass='" + hashPwd + "',regdate='" + regdate + "',status='" + status + "',access='" + access + "' WHERE uname='" + uname + "'"
872                 Dim updatecmd As New OleDbCommand
873                 With updatecmd
874                     .CommandText = updateqry
875                     .Connection = connect
876                     .ExecuteNonQuery()
877                 End With
878                 MsgBox(
"User informations updated successfuly", MsgBoxStyle.Information, "Success")
879                 clearinputs_manageuser()
880                 viewusers()
881             End If
882
883         Else
884             
'for log file
885             
'Dim uname As String =frmlogin.lbluname.text
886             Dim unamelog As String =
"cngirwa"
887             Dim activity As String = unamelog +
" added new user with username " + uname
888             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
889             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
890             Dim insertlogcmd As New OleDbCommand
891             With insertlogcmd
892                 .CommandText = insertlog
893                 .Connection = connect
894                 .ExecuteNonQuery()
895             End With
896
897             Dim insertqry As String =
"INSERT INTO users(fname,mname,lname,email,dob,sex,mobile,marital,role,uname,upass,regdate,status,access) VALUES('" + fname + "','" + mname + "','" + lname + "','" + email + "','" + dob + "','" + sex + "','" + mobile + "','" + marital + "','" + role + "','" + uname + "','" + hashPwd + "','" + regdate + "','" + status + "','" + access + "')"
898             Dim insertcmd As New OleDbCommand
899             With insertcmd
900                 .CommandText = insertqry
901                 .Connection = connect
902                 .ExecuteNonQuery()
903             End With
904             MsgBox(
"New user added successfuly", MsgBoxStyle.Information, "Success")
905             clearinputs_manageuser()
906             viewusers()
907         End If
908     End Sub
909
910     Private Sub btnManageuserclear_Click(sender As System.Object, e As System.EventArgs) Handles btnManageuserclear.Click
911         clearinputs_manageuser()
912     End Sub
913
914     Private Sub clearinputs_manageuser()
915         txtManageuserfname.Clear()
916         txtManageusermname.Clear()
917         txtManageuserlname.Clear()
918         txtManageuseremail.Clear()
919         txtManageusermobile.Clear()
920         txtManageuseruname.Clear()
921         txtManageuserpassword.Clear()
922         txtManageusercpassword.Clear()
923         lbldeleteuname.Text =
""
924     End Sub
925
926     Private Sub btnManageuserDelete_Click(sender As System.Object, e As System.EventArgs) Handles btnManageuserDelete.Click
927         Dim uname As String = lbldeleteuname.Text
928         Dim deleteqry As String =
"DELETE * FROM users WHERE uname='" + uname + "'"
929         Dim deletecmd As New OleDbCommand
930         Dim confirm As String
931
932         If uname = frmLogin.lbluname.Text Then
933             MsgBox(
"You can not delete you own account", MsgBoxStyle.Critical, "Error")
934             Exit Sub
935         Else
936         End If
937
938         confirm = MessageBox.Show(
"Are you sure you want to delete user " & uname & "?", "Delete username " & uname, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
939         If confirm = MsgBoxResult.No Then
940             Me.Refresh()
941         Else
942             
'for log file
943             Dim uname1 As String = frmLogin.lbluname.Text
944             Dim unamelog As String = uname1
945             Dim activity As String = unamelog +
" deleted a user with username " + uname1
946             Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
947             Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
948             Dim insertlogcmd As New OleDbCommand
949             With insertlogcmd
950                 .CommandText = insertlog
951                 .Connection = connect
952                 .ExecuteNonQuery()
953             End With
954
955             With deletecmd
956                 .CommandText = deleteqry
957                 .Connection = connect
958                 .ExecuteNonQuery()
959             End With
960             MsgBox(
"User deleted successfuly", MsgBoxStyle.Information, "Success")
961             viewusers()
962             clearinputs_manageuser()
963         End If
964     End Sub
965
966     Private Sub viewusers()
967         Dim selectqry As String =
"SELECT id,fname,lname,sex,mobile,role,uname,status FROM users"
968
969         Dim da As OleDbDataAdapter
970         da = New OleDbDataAdapter(selectqry, connect)
971
972         Dim dtset As DataSet
973         dtset = New DataSet()
974         da.Fill(dtset,
"users")
975
976         Dim dttable As DataTable
977         dttable = New DataTable
978         dttable = dtset.Tables(
"users")
979
980         dgvManageruser.DataSource = dttable
981         dgvManageruser.ColumnHeadersDefaultCellStyle.Font = New Font(dgvManageruser.Font, FontStyle.Bold)
982         dgvManageruser.Font = New Font(dgvManageruser.Font, FontStyle.Regular)
983         dgvManageruser.ForeColor = Color.Black
984
985         dgvManageruser.Columns(
"ID").HeaderText = "ID"
986         dgvManageruser.Columns(
"ID").Width = 30
987
988         dgvManageruser.Columns(
"fname").HeaderText = "First Name"
989         dgvManageruser.Columns(
"fname").Width = 150
990
991         dgvManageruser.Columns(
"lname").HeaderText = "Last Name"
992         dgvManageruser.Columns(
"lname").Width = 150
993
994         dgvManageruser.Columns(
"sex").HeaderText = "Sex"
995         dgvManageruser.Columns(
"sex").Width = 60
996
997         dgvManageruser.Columns(
"mobile").HeaderText = "Mobile"
998         dgvManageruser.Columns(
"mobile").Width = 100
999
1000         dgvManageruser.Columns(
"role").HeaderText = "Role"
1001         dgvManageruser.Columns(
"role").Width = 90
1002
1003         dgvManageruser.Columns(
"uname").HeaderText = "Username"
1004         dgvManageruser.Columns(
"uname").Width = 100
1005
1006         dgvManageruser.Columns(
"status").HeaderText = "Status"
1007         dgvManageruser.Columns(
"status").Width = 110
1008
1009     End Sub
1010
1011     Private Sub btnManageusersearch_Click(sender As System.Object, e As System.EventArgs) Handles btnManageusersearch.Click
1012         Dim search As String = txtManageusersearch.Text.Trim
1013         If (search =
"" Or IsNothing(search) = True) Then
1014             MsgBox(
"Please enter something to search", MsgBoxStyle.Information, "Error")
1015             txtManageusersearch.Focus()
1016         Else
1017             txtManageusersearch.Clear()
1018             Dim searchqry As String =
"SELECT id,fname,lname,sex,mobile,role,uname,status FROM users WHERE id LIKE '%" + search + "%' OR fname LIKE '%" + search + "%' OR lname LIKE '%" + search + "%' OR sex LIKE '%" + search + "%' OR mobile LIKE '%" + search + "%' OR role LIKE '%" + search + "%' OR uname LIKE '%" + search + "%' OR status LIKE '%" + search + "%'"
1019
1020             Dim da As OleDbDataAdapter
1021             da = New OleDbDataAdapter(searchqry, connect)
1022
1023             Dim dtset As DataSet
1024             dtset = New DataSet()
1025             da.Fill(dtset,
"users")
1026
1027             Dim dttable As DataTable
1028             dttable = New DataTable
1029             dttable = dtset.Tables(
"users")
1030
1031             dgvManageruser.DataSource = dttable
1032             dgvManageruser.ColumnHeadersDefaultCellStyle.Font = New Font(dgvManageruser.Font, FontStyle.Bold)
1033             dgvManageruser.Font = New Font(dgvManageruser.Font, FontStyle.Regular)
1034             dgvManageruser.ForeColor = Color.Black
1035
1036             dgvManageruser.Columns(
"ID").HeaderText = "ID"
1037             dgvManageruser.Columns(
"ID").Width = 30
1038
1039             dgvManageruser.Columns(
"fname").HeaderText = "First Name"
1040             dgvManageruser.Columns(
"fname").Width = 150
1041
1042             dgvManageruser.Columns(
"lname").HeaderText = "Last Name"
1043             dgvManageruser.Columns(
"lname").Width = 150
1044
1045             dgvManageruser.Columns(
"sex").HeaderText = "Sex"
1046             dgvManageruser.Columns(
"sex").Width = 60
1047
1048             dgvManageruser.Columns(
"mobile").HeaderText = "Mobile"
1049             dgvManageruser.Columns(
"mobile").Width = 100
1050
1051             dgvManageruser.Columns(
"role").HeaderText = "Role"
1052             dgvManageruser.Columns(
"role").Width = 90
1053
1054             dgvManageruser.Columns(
"uname").HeaderText = "Username"
1055             dgvManageruser.Columns(
"uname").Width = 100
1056
1057             dgvManageruser.Columns(
"status").HeaderText = "Status"
1058             dgvManageruser.Columns(
"status").Width = 110
1059         End If
1060     End Sub
1061
1062     Private Sub btnManageuserRefresh_Click(sender As System.Object, e As System.EventArgs) Handles btnManageuserRefresh.Click
1063         viewusers()
1064         clearinputs_manageuser()
1065     End Sub
1066
1067     Private Sub dgvManageruser_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvManageruser.CellContentClick
1068         Dim s As System.Drawing.Point
1069         s = dgvManageruser.CurrentCellAddress
1070         Try
1071             Dim dbid As String = dgvManageruser.Item(
"uname", s.Y).Value.ToString
1072             lbldeleteuname.Text = dbid
1073         Catch ex As Exception
1074             MsgBox(
"Please select a user to delete", MessageBoxIcon.Warning, "Error")
1075         End Try
1076         
1077     End Sub
1078
1079     Private Sub btnManageuserEdit_Click(sender As System.Object, e As System.EventArgs) Handles btnManageuserEdit.Click
1080
1081         Dim uname As String = lbldeleteuname.Text
1082         Dim selectqry As String =
"SELECT * FROM users WHERE uname= '" + uname + "'"
1083
1084         If (lbldeleteuname.Text =
"") Or (IsNothing(lbldeleteuname.Text) = True) Then
1085             MsgBox(
"Select a user to edit", MsgBoxStyle.Information, "Error")
1086
1087         Else
1088             Dim da As OleDbDataAdapter
1089             da = New OleDbDataAdapter(selectqry, connect)
1090
1091             Dim dtset As DataSet
1092             dtset = New DataSet()
1093             da.Fill(dtset,
"users")
1094
1095             Dim dttable As DataTable
1096             dttable = New DataTable
1097             dttable = dtset.Tables(
"users")
1098
1099             Dim dbfname, dbmname, dblname, dbemail, dbdob, dbgender, dbmobile, dbmarital, dbrole, dbuname As String
1100             For Each temprow In dttable.Rows
1101                 dbfname = temprow(
"fname").ToString
1102                 dbmname = temprow(
"mname").ToString
1103                 dblname = temprow(
"lname").ToString
1104                 dbemail = temprow(
"email").ToString
1105                 dbdob = temprow(
"dob").ToString
1106                 dbgender = temprow(
"sex").ToString
1107                 dbmobile = temprow(
"mobile").ToString
1108                 dbmarital = temprow(
"marital").ToString
1109                 dbrole = temprow(
"role").ToString
1110                 dbuname = temprow(
"uname").ToString
1111             Next
1112
1113             txtManageuserfname.Text = dbfname
1114             txtManageusermname.Text = dbmname
1115             txtManageuserlname.Text = dblname
1116             txtManageuseremail.Text = dbemail
1117             dtpManageuserdob.Text = dbdob
1118             cbManageusersex.Text = dbgender
1119             txtManageusermobile.Text = dbmobile
1120             cbManageusermarital.Text = dbmarital
1121             cbManageuserRole.Text = dbrole
1122             txtManageuseruname.Text = dbuname
1123
1124         End If
1125     End Sub
1126
1127     Private Sub txtManageusermobile_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtManageusermobile.TextChanged
1128         If txtManageusermobile.Text =
"" Then
1129             txtManageusermobile.Clear()
1130             Exit Sub
1131         ElseIf IsNumeric(txtManageusermobile.Text) = False Then
1132             MsgBox(
"Only numbers are allowed", MessageBoxIcon.Warning, "Error")
1133             txtManageusermobile.Clear()
1134             Exit Sub
1135         End If
1136     End Sub
1137 #End Region
1138
1139 #Region
"VIEW LOGS"
1140     Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
1141         enablebtns()
1142         btnLog.Enabled = False
1143         hidegb()
1144         gbActivitylog.Dock = DockStyle.Fill
1145         gbActivitylog.Show()
1146         viewlog()
1147     End Sub
1148
1149     Private Sub viewlog()
1150         
'for log file
1151         
'Dim uname As String =frmlogin.lbluname.text
1152         Dim unamelog As String =
"cngirwa"
1153         Dim activity As String = unamelog +
" viewed activity log file"
1154         Dim activitydate As String = lblTime.Text +
" " + lblDate.Text
1155         Dim insertlog As String =
"INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
1156         Dim insertlogcmd As New OleDbCommand
1157         With insertlogcmd
1158             .CommandText = insertlog
1159             .Connection = connect
1160             .ExecuteNonQuery()
1161         End With
1162
1163         Dim selectqry As String =
"SELECT * FROM logfiles"
1164
1165         Dim da As OleDbDataAdapter
1166         da = New OleDbDataAdapter(selectqry, connect)
1167
1168         Dim dtset As DataSet
1169         dtset = New DataSet()
1170         da.Fill(dtset,
"logfiles")
1171
1172         Dim dttable As DataTable
1173         dttable = New DataTable()
1174         dttable = dtset.Tables(
"logfiles")
1175
1176         dgvActivitylog.DataSource = dttable
1177         dgvActivitylog.ColumnHeadersDefaultCellStyle.Font = New Font(dgvActivitylog.Font, FontStyle.Bold)
1178         dgvActivitylog.Font = New Font(dgvActivitylog.Font, FontStyle.Regular)
1179         dgvActivitylog.ForeColor = Color.Black
1180
1181         dgvActivitylog.Columns(
"uname").HeaderText = "Username"
1182         dgvActivitylog.Columns(
"uname").Width = 120
1183
1184         dgvActivitylog.Columns(
"activity").HeaderText = "Activities done by user"
1185         dgvActivitylog.Columns(
"activity").Width = 700
1186
1187         dgvActivitylog.Columns(
"activitydate").HeaderText = "Time and date the activity was done"
1188         dgvActivitylog.Columns(
"activitydate").Width = 310
1189
1190     End Sub
1191
1192
1193     Private Sub btnActivitysearch_Click(sender As System.Object, e As System.EventArgs) Handles btnActivitysearch.Click
1194         Dim search As String = txtActivitysearch.Text.Trim
1195         If (search =
"" Or IsNothing(search) = True) Then
1196             MsgBox(
"Please enter something to search", MsgBoxStyle.Information, "Error")
1197             txtActivitysearch.Focus()
1198         Else
1199             txtActivitysearch.Clear()
1200             Dim searchqry As String =
"SELECT * FROM logfiles WHERE uname LIKE '%" + search + "%' OR activity LIKE '%" + search + "%' OR activitydate LIKE '%" + search + "%'"
1201             Dim da As OleDbDataAdapter
1202             da = New OleDbDataAdapter(searchqry, connect)
1203
1204             Dim dtset As DataSet
1205             dtset = New DataSet()
1206             da.Fill(dtset,
"logfiles")
1207
1208             Dim dttable As DataTable
1209             dttable = New DataTable()
1210             dttable = dtset.Tables(
"logfiles")
1211
1212             dgvActivitylog.DataSource = dttable
1213             dgvActivitylog.ColumnHeadersDefaultCellStyle.Font = New Font(dgvActivitylog.Font, FontStyle.Bold)
1214             dgvActivitylog.Font = New Font(dgvActivitylog.Font, FontStyle.Regular)
1215             dgvActivitylog.ForeColor = Color.Black
1216
1217             dgvActivitylog.Columns(
"uname").HeaderText = "Username"
1218             dgvActivitylog.Columns(
"uname").Width = 120
1219
1220             dgvActivitylog.Columns(
"activity").HeaderText = "Activities done by user"
1221             dgvActivitylog.Columns(
"activity").Width = 700
1222
1223             dgvActivitylog.Columns(
"activitydate").HeaderText = "Time and date the activity was done"
1224             dgvActivitylog.Columns(
"activitydate").Width = 310
1225         End If
1226     End Sub
1227 #End Region
1228
1229 #Region
"SETTINGS"
1230     Private Sub btnSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSettings.Click
1231         enablebtns()
1232         btnSettings.Enabled = False
1233         hidegb()
1234         gbSetting.Dock = DockStyle.Fill
1235         gbSetting.Show()
1236         clearinputs_settings()
1237     End Sub
1238
1239     Private Sub btnCheckupdates_Click(sender As System.Object, e As System.EventArgs) Handles btnCheckupdates.Click
1240         lblUpdates.Show()
1241         pbUpdates.Show()
1242         Me.Enabled = False
1243
1244         Dim response As System.Net.HttpWebResponse
1245         Try
1246             Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(
"https://googledrive.com/host/0BzlScedc3p2fUEQ0MjJFa1cxUWM/Tool Update.txt")
1247             response = request.GetResponse()
1248         Catch ex As Exception
1249           
1250             MsgBox(
"Error occured. Please try again", MessageBoxIcon.Warning, "Error")
1251             lblUpdates.Hide()
1252             pbUpdates.Hide()
1253             Me.Enabled = True
1254             Exit Sub
1255         End Try
1256         Dim sr As StreamReader = New StreamReader(response.GetResponseStream())
1257
1258         Dim newsoftversion As String = sr.ReadToEnd()
1259         Dim currentsoftversion As String = Application.ProductVersion
1260
1261         lblUpdates.Hide()
1262         pbUpdates.Hide()
1263         If newsoftversion.Contains(currentsoftversion) Then
1264             MsgBox(
"You have updated software version", MsgBoxStyle.Information, "Update")
1265             Me.Enabled = True
1266         Else
1267             Dim updatesoft As String
1268             updatesoft = MessageBox.Show(
"There is a new software version. Do you want to update now?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
1269             If updatesoft = MsgBoxResult.Yes Then
1270                 System.Diagnostics.Process.Start(
"https://googledrive.com/host/0BzlScedc3p2fUEQ0MjJFa1cxUWM/Stationary Information System.exe")
1271                 Me.Enabled = True
1272             Else
1273                 MsgBox(
"Update cancelled", MsgBoxStyle.Information, "Cancel")
1274                 Me.Enabled = True
1275             End If
1276
1277         End If
1278
1279     End Sub
1280
1281     Private Sub clearinputs_settings()
1282         txtMailTo.Clear()
1283         lblMailattach.Text =
"No attachment selected"
1284     End Sub
1285
1286     Private Sub btnMailsend_Click(sender As System.Object, e As System.EventArgs) Handles btnMailsend.Click
1287         Dim attachlocation As String = lblMailattach.Text
1288         If StrComp(attachlocation,
"No attachment selected") <> 0 Then
1289             Dim uname As String =
"sis.manager.backup@gmail.com"
1290             Dim pass As String =
"sis.manager"
1291             Dim receiver As String = txtMailTo.Text.Trim
1292             Dim subject As String =
"Backup File"
1293             Dim body As String =
"Please find an attachment on this E-Mail. It contains your backup file which you created on " + lblTime.Text + " : " + lblDate.Text
1294             Dim attach As New Attachment(attachlocation)
1295             Dim mail As New MailMessage()
1296
1297
1298             If (StrComp(receiver,
"") <> 0) And (attachlocation <> "No attachment selected") Then
1299                 Try
1300                     mail.From = New MailAddress(uname)
1301                     mail.To.Add(receiver)
1302                     mail.Subject = subject
1303                     mail.Body = body
1304                     mail.Attachments.Add(attach)
1305
1306                     Dim smtpsettings As New SmtpClient(
"smtp.gmail.com")
1307                     smtpsettings.Port =
587
1308                     smtpsettings.Credentials = New System.Net.NetworkCredential(uname, pass)
1309                     smtpsettings.EnableSsl = True
1310                     Try
1311                         Me.Enabled = False
1312                         Me.WindowState = FormWindowState.Normal
1313                         smtpsettings.Send(mail)
1314                         MsgBox(
"A backup copy is sent successfuly", MsgBoxStyle.Information, "Success")
1315                         clearinputs_settings()
1316                         Me.Enabled = True
1317                     Catch ex As Exception
1318                         MsgBox(ex.Message, MessageBoxIcon.Error,
"Error")
1319                         Me.Enabled = True
1320                     End Try
1321                 Catch ex As Exception
1322                     MsgBox(ex.Message, MessageBoxIcon.Error,
"Error")
1323                     Me.Enabled = True
1324                 End Try
1325             Else
1326                 MsgBox(
"Error occured. Please fill all fields correctly", MessageBoxIcon.Warning, "Error")
1327             End If
1328         Else
1329             MsgBox(
"Error occured. Please make backup first", MessageBoxIcon.Warning, "Error")
1330             clearinputs_settings()
1331         End If
1332     End Sub
1333
1334     Private Sub btnRestorebackup_Click(sender As System.Object, e As System.EventArgs) Handles btnRestorebackup.Click
1335         Me.Enabled = False
1336         MsgBox(
"Please choose the backup database which you have downloaded from your e-mail", MsgBoxStyle.Information, "Stationary Information System")
1337         With ofdRestore
1338             .Filter =
"Database file (*.accdb)|*.accdb"
1339             .Title =
"Select Database file"
1340             .FileName =
""
1341         End With
1342         If Me.ofdRestore.ShowDialog = DialogResult.Cancel Then
1343             Me.Enabled = True
1344             Exit Sub
1345         End If
1346     End Sub
1347
1348     Private Sub ofdRestore_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles ofdRestore.FileOk
1349         Dim backuplocation As String
1350         backuplocation = Path.GetFullPath(ofdRestore.FileName)
1351
1352         Dim currentDir As String = My.Computer.FileSystem.CurrentDirectory.ToString()
1353         Directory.SetCurrentDirectory(currentDir)
1354         Directory.CreateDirectory(currentDir &
"\error db\")
1355         Dim olddb As String = currentDir & "
\error db\"
1356
1357         Try
1358             If File.Exists("
sis.accdb") Then
1359                 closeconnection()
1360                 File.Copy(currentDir & "
\sis.accdb", olddb & "sis.accdb", True)
1361                 File.Delete(currentDir & "
\sis.accdb")
1362                 File.Copy(backuplocation, currentDir & "
\sis.accdb", True)
1363                 MsgBox("
Restore succefully!123312", MsgBoxStyle.Information, "Success")
1364                 MsgBox("
S.I.S will now shutdown in order for changes to take effects", MessageBoxIcon.Warning, "Warning")
1365                 Me.Dispose()
1366                 Me.Close()
1367
1368             Else
1369                 closeconnection()
1370                 File.Copy(currentDir & "
\sis.accdb", olddb)
1371                 File.Copy(backuplocation, currentDir)
1372                 MsgBox("
Restore succefully!", MsgBoxStyle.Information, "Success")
1373                 MsgBox("
S.I.S will now shutdown in order for changes to take effects", MessageBoxIcon.Warning, "Warning")
1374                 Me.Dispose()
1375                 Me.Close()
1376             End If
1377         Catch ex As Exception
1378             MsgBox("
Error occured. Please try again", MsgBoxStyle.Information, "Error")
1379         End Try
1380
1381         Me.Enabled = True
1382     End Sub
1383
1384     Private Sub btnSavebackup_Click(sender As System.Object, e As System.EventArgs) Handles btnSavebackup.Click
1385         Me.Enabled = False
1386         MsgBox("
Please choose location to save a backup database, then send it to your e-mail", MsgBoxStyle.Information, "Stationary Information System")
1387         With sfdBackup
1388             .Filter = "
Database file (*.accdb)|*.accdb"
1389             .Title = "
Choose location"
1390             .FileName = ""
1391         End With
1392         If Me.sfdBackup.ShowDialog = DialogResult.Cancel Then
1393             Me.Enabled = True
1394             Exit Sub
1395         End If
1396     End Sub
1397
1398     Private Sub sfdBackup_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles sfdBackup.FileOk
1399         Dim backuplocation As String
1400         backuplocation = Path.GetFullPath(sfdBackup.FileName)
1401         lblMailattach.Text = backuplocation
1402
1403         Dim currentDir As String = My.Computer.FileSystem.CurrentDirectory.ToString()
1404         Directory.SetCurrentDirectory(currentDir)
1405         Try
1406             If File.Exists("
sis.accdb") Then
1407                 closeconnection()
1408                 File.Copy(currentDir & "
\sis.accdb", backuplocation, True)
1409                 MsgBox("
Backup succefully!123312", MsgBoxStyle.Information, "Success")
1410                 MsgBox("
Please send the backup file to your e-mail", MessageBoxIcon.Warning, "Warning")
1411
1412             Else
1413                 MsgBox("
Error occured. Please try again", MsgBoxStyle.Information, "Error")
1414             End If
1415         Catch ex As Exception
1416             MsgBox("
Error occured. Please try again", MsgBoxStyle.Information, "Error")
1417         End Try
1418
1419         Me.Enabled = True
1420     End Sub
1421 #End Region
1422
1423 #Region "
HELP"
1424     Private Sub btnHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHelp.Click
1425         enablebtns()
1426         btnHelp.Enabled = False
1427         hidegb()
1428         gbHelp.Dock = DockStyle.Fill
1429         gbHelp.Show()
1430     End Sub
1431 #End Region
1432
1433 #Region "
LOGOUT"
1434     Private Sub btnLogout_Click(sender As System.Object, e As System.EventArgs) Handles btnLogout.Click
1435         Dim logout As String
1436         logout = MessageBox.Show("
Are you sure you want to logout?", "Stationary Information System", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
1437         If logout = MsgBoxResult.No Then
1438             Me.Refresh()
1439             enablebtns()
1440             btnHome.Enabled = False
1441             hidegb()
1442             gbHome.Dock = DockStyle.Fill
1443             gbHome.Show()
1444             clearinputs_home()
1445         Else
1446             '
for log file
1447             Dim uname As String = frmLogin.lbluname.Text
1448             Dim unamelog As String = uname
1449             Dim activity As String = unamelog + "
logged out "
1450             Dim activitydate As String = lblTime.Text + "
" + lblDate.Text
1451             Dim insertlog As String = "
INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
1452             Dim insertlogcmd As New OleDbCommand
1453             With insertlogcmd
1454                 .CommandText = insertlog
1455                 .Connection = connect
1456                 .ExecuteNonQuery()
1457             End With
1458
1459             Dim updateqry As String = "
UPDATE users SET access='LOGOUT' WHERE uname='" + uname + "'"
1460             Dim updatecmd As New OleDbCommand
1461             With updatecmd
1462                 .CommandText = updateqry
1463                 .Connection = connect
1464                 .ExecuteNonQuery()
1465             End With
1466
1467             frmLogin.Show()
1468             Me.Dispose()
1469             closeconnection()
1470         End If
1471     End Sub
1472 #End Region
1473
1474 #End Region
1475
1476
1477 #Region "
Form actions"
1478     Private Sub frmAdminENG_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
1479         openconnection()
1480         Dim close As String
1481         close = MessageBox.Show("
Are you sure you want to close?", "Stationary Information System", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
1482         If close = MsgBoxResult.No Then
1483             Me.Refresh()
1484             e.Cancel = True
1485         Else
1486             '
for log file
1487             Dim uname As String = frmLogin.lbluname.Text
1488             Dim unamelog As String = uname
1489             Dim activity As String = unamelog + "
logged out "
1490             Dim activitydate As String = lblTime.Text + "
" + lblDate.Text
1491             Dim insertlog As String = "
INSERT INTO logfiles VALUES('" + unamelog + "','" + activity + "','" + activitydate + "')"
1492             Dim insertlogcmd As New OleDbCommand
1493             With insertlogcmd
1494                 .CommandText = insertlog
1495                 .Connection = connect
1496                 .ExecuteNonQuery()
1497             End With
1498
1499             Dim updateqry As String = "
UPDATE users SET access='LOGOUT' WHERE uname='" + uname + "'"
1500             Dim updatecmd As New OleDbCommand
1501             With updatecmd
1502                 .CommandText = updateqry
1503                 .Connection = connect
1504                 .ExecuteNonQuery()
1505             End With
1506
1507             frmLogin.Show()
1508             Me.Dispose()
1509             closeconnection()
1510
1511         End If
1512     End Sub
1513
1514     Private Sub frmAdminENG_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
1515         TimerDate.Start()
1516         hidegb()
1517         gbHome.Dock = DockStyle.Fill
1518         gbHome.Show()
1519         enablebtns()
1520         btnHome.Enabled = False
1521         openconnection()
1522         viewnews()
1523     End Sub
1524
1525 #End Region
1526
1527 #Region "
Time, Date and Zone"
1528     Private Sub TimerDate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerDate.Tick
1529         lblTime.Text = TimeOfDay
1530         lblDate.Text = Today.Date.ToString("
dddd, dd MMMM yyyy")
1531         lblZone.Text = TimeZone.CurrentTimeZone.StandardName
1532     End Sub
1533 #End Region
1534
1535 #Region "
Hide all gb"
1536     Private Sub hidegb()
1537         gbSetting.Hide()
1538         gbActivitylog.Hide()
1539         gbAddstock.Hide()
1540         gbHelp.Hide()
1541         gbHome.Hide()
1542         gbManageusers.Hide()
1543         gbReport.Hide()
1544         gbViewsales.Hide()
1545         gbViewstock.Hide()
1546     End Sub
1547 #End Region
1548
1549 #Region "
Enable all Buttons"
1550     Private Sub enablebtns()
1551         btnHome.Enabled = True
1552         btnAddstock.Enabled = True
1553         btnViewstock.Enabled = True
1554         btnViewsales.Enabled = True
1555         btnReport.Enabled = True
1556         btnManageaccounts.Enabled = True
1557         btnLog.Enabled = True
1558         btnSettings.Enabled = True
1559         btnHelp.Enabled = True
1560         btnLog.Enabled = True
1561     End Sub
1562 #End Region
1563
1564 #Region "
notification icon"
1565     Private Sub frmAdminENG_Move(sender As Object, e As System.EventArgs) Handles Me.Move
1566         If Me.WindowState = FormWindowState.Minimized Then
1567             Me.Hide()
1568             niSIS.ShowBalloonTip(
4600, "Stationary Information System", "Stationary Information System have been minimized. Click this icon to maximise it", ToolTipIcon.Info)
1569         End If
1570     End Sub
1571
1572     Private Sub niSIS_MouseDoubleClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles niSIS.MouseDoubleClick
1573         Me.Show()
1574         Me.WindowState = FormWindowState.Normal
1575     End Sub
1576 #End Region
1577
1578 End Class


Gõ tìm kiếm nhanh...